<template>
	<view>
		<s-pull-scroll ref="pullScroll" :fixed="false" :back-top="false"  :pullDown="pullDown" :pullUp="loadData">
			<div style="width: 100%;height: 300px;">111</div>
			<wateFull ref="wateFull" :list="list"/>
		</s-pull-scroll>
	</view>
</template>

<script>
	import wateFull from '@/components/watefull/watefull.vue'
	export default {
		components:{
			wateFull
		},
		data() {
			return {				
				curPage:1,
				list:[],
				total:''
			}
		},
		onLoad() {
			this.refresh()
		},
		methods: {
			refresh () {
			  this.$nextTick(() => {
				this.$refs.pullScroll.refresh();
			  });
		    },
			//下拉刷新
			pullDown(pullScroll){
				 setTimeout(() => {
				   this.curPage=0
				   this.loadData(pullScroll);
				 }, 200);
			},
			//下拉加载
			loadData(pullScroll){
				setTimeout(()=>{
					this.curPage++
					this.getTopicList(pullScroll)
				},200)
			},
			getTopicList(pullScroll){
				var _ = this;
				uni.request({
				    // url: 'http://rest.apizza.net/mock/fe9366984f17aa16ab1e5076d89365c8/api/waimai/topic_list',
					url:`http://193.112.216.112:8110/book/app/book/index/getChildCategoryBookList/${this.curPage}/6/1`,
				    success: (res) => {
						this.total= res.data.data.total
						this.list = res.data.data.rows;
						if(this.list.length>0){
							this.curPage===1?this.list=res.data.data.rows:this.list.concat(res.data.data.rows)
						}else{
							 pullScroll.finish(); //表示全部加载完毕
						}
						if(this.total===0){
								pullScroll.empty();  //表示为空 
							 }else if(this.list.length>=this.total){
								 pullScroll.finish(); //表示全部加载完毕
							 }else{
								pullScroll.success(); // 表示加载成功
						 }
				    }
				});
				
			},
		}
	}
</script>

<style lang="less" scoped>

</style>

